package com.dxysun.mine.elasticjob;

import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.dataflow.job.DataflowJob;

import java.util.ArrayList;
import java.util.List;

public class MyElasticJob implements DataflowJob<String>
{

    @Override
    public List<String> fetchData(ShardingContext context) {
        List<String> data = new ArrayList<>();
        switch (context.getShardingItem()) {
            case 0:
//                List<Foo> data = // get data from database by sharding item 0
                return data;
            case 1:
//                List<Foo> data = // get data from database by sharding item 1
                return data;
            case 2:
//                List<Foo> data = // get data from database by sharding item 2
                return data;
            // case n: ...
        }
        return data;
    }

    @Override
    public void processData(ShardingContext shardingContext, List<String> data) {
        // process data
        // ...
    }
}